package com.example.framework.common.util;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.example.framework.common.constant.BaseConstants;
import lombok.experimental.UtilityClass;

@UtilityClass
public class TraceIdGenerateUtils {

    public static String traceId(String prefix) {
        String traceId = IdUtil.getSnowflakeNextIdStr();
        if (StrUtil.isNotBlank(prefix)) {
            traceId = String.format(BaseConstants.TRACE_ID_IN, prefix, traceId);
        }
        return traceId;
    }

    public static String newTraceId() {
        return traceId("");
    }

}
